package com.nulldev.util.web.YouTubeExtractor.comments.handlers;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.data.Variables;
import com.nulldev.util.languages.json.uniapi.UniJsonValue;

final class Util {
	static boolean __hasCreatorHeart(final UniJsonValue o) {
		if (o == null)
			return false;
		if (!o.contains("actionButtons"))
			return false;
		final UniJsonValue actionButtons = o.get("actionButtons");
		if (!actionButtons.contains("commentActionButtonsRenderer"))
			return false;
		final UniJsonValue commentActionButtonsRenderer = actionButtons.get("commentActionButtonsRenderer");
		if (!commentActionButtonsRenderer.contains("creatorHeart"))
			return false;
		if (!commentActionButtonsRenderer.get("creatorHeart").contains("creatorHeartRenderer"))
			return false;
		final UniJsonValue creatorHeartRenderer = commentActionButtonsRenderer.get("creatorHeart").get("creatorHeartRenderer");
		return creatorHeartRenderer.bool("isHearted");
	}

	static boolean isVerified(final UniJsonValue u) {
		try {
			if (Variables.requireNonNullObject(u, "u").hasValue("ownerBadges")) {
				for (final UniJsonValue badge : u.get("ownerBadges").asArray()) {
					return badge.get("metadataBadgeRenderer").getString("style").equalsIgnoreCase("BADGE_STYLE_TYPE_VERIFIED");
				}
			}
		} catch (Exception e) {
			JVM.errorln(e);
		}
		return false;
	}

}
